import instance from "./index";
import qs from "qs";
// export function createDepartment(data) {
//   return instance({
//     url: "/dept/create",
//     method: "post",
//     data,
//   });
// }

function buildOptions(data: any, url: string, method?: string) {
  const options: any = {
    method: method || "POST",
    url,
  };
  if (options.method === "GET") {
    options.params = data;
  } else {
    options.data = qs.stringify(data);
  }
  return options;
}

export async function createDepartment(data: any) {
  const options = buildOptions(data, "hr/dept/create");
  return instance(options);
}

export async function getDepartmentlist(data: any) {
  const options = buildOptions(data, "hr/dept/list");
  return instance(options);
}

export async function Departmentedit(data: any) {
  const options = buildOptions(data, "hr/dept/edit");
  return instance(options);
}

export async function Departmentdel(data: any) {
  const options = buildOptions(data, "hr/dept/del");
  return instance(options);
}

//添加编辑员工-紧急联系人
// export async function save_urgent(data: any) {
//   const options = buildOptions(data, "user/save");
//   return instance(options);
// }

//政治面貌
export async function getpolitical() {
  const options = buildOptions("", "hr/user/political", "GET");
  return instance(options);
}

//婚姻状况
export async function getmarital() {
  const options = buildOptions("", "hr/user/marital", "GET");
  return instance(options);
}
//用工形式
export async function getjobmode() {
  const options = buildOptions("", "hr/user/job_mode", "GET");
  return instance(options);
}

//用工形式
export async function saveyuangong(data) {
  const options = buildOptions(data, "hr/user/save");
  return instance(options);
}

export async function save_info(data) {
  const options = buildOptions(data, "hr/user/save_info");
  return instance(options);
}
//员工列表
export async function user_list(data) {
  const options = buildOptions(data, "hr/user/user_list");
  return instance(options);
}

//员工 删除
export async function user_delete(data) {
  const options = buildOptions(data, "hr/user/user_delete?id=" + data, "GET");
  return instance(options);
}

//邀请员工
export async function invite_user(data) {
  const options = buildOptions(data, "hr/user/invite_user");
  return instance(options);
}

//添加编辑员工- 个人信息
export async function save_person(data) {
  const options = buildOptions(data, "hr/user/save_person");
  return instance(options);
}

//添加编辑员工-紧急联系人
export async function save_urgent(data) {
  const options = buildOptions(data, "hr/user/save_urgent");
  return instance(options);
}

//添加编辑员工-工资卡信息
export async function save_salary(data) {
  const options = buildOptions(data, "hr/user/save_salary");
  return instance(options);
}
//添加编辑员工-入职信息
export async function save_jobinfo(data) {
  const options = buildOptions(data, "hr/user/save_jobinfo");
  return instance(options);
}
//获取员工信息
export async function user_info(data) {
  const options = buildOptions(data, "hr/user/user_info?id=" + data, "GET");
  return instance(options);
}

//自定义导入
export async function zidingyiupload(data) {
  const options = buildOptions(data, "hr/Userinfo/upload");
  return instance(options);
}

export async function zidingyidaoru(data) {
  const options = buildOptions(data, "hr/Userinfo/daoru");
  return instance(options);
}

export async function bind_ding(data) {
  const options = buildOptions(data, "hr/userinfo/bind_ding");
  return instance(options);
}

export async function importEmployees() {
  const options = buildOptions("", "hr/DingTalk/importEmployees", "GET");
  return instance(options);
}

export async function cate_list() {
  const options = buildOptions("", "hr/risk/cate_list", "GET");
  return instance(options);
}

export async function gethtlist(id) {
  const options = buildOptions("", "hr/risk/list?cate_id=" + id, "GET");
  return instance(options);
}

export async function statistics() {
  const options = buildOptions("", "hr/statistics/statistics", "GET");
  return instance(options);
}

export async function import_log(data) {
  const options = buildOptions(data, "hr/userinfo/import_log");
  return instance(options);
}

export async function template() {
  const options = buildOptions("", "hr/userinfo/template", "GET");
  return instance(options);
}

export async function ocr(data) {
  const options = buildOptions(data, "hr/index/ocr");
  return instance(options);
}

export async function company_aes(data) {
  const options = buildOptions(data, "hr/userinfo/company_aes");
  return instance(options);
}

export async function ding_bind_url(data) {
  const options = buildOptions(data, "hr/userinfo/ding_bind_url", "GET");
  return instance(options);
}

export async function ApplyList(data: any) {
  const options = buildOptions(data, "hr/company/company_apply_list", "GET");
  return instance(options);
}

export async function CompanyInfo(data: any) {
  const options = buildOptions(data, "hr/company/company_info");
  return instance(options);
}

export async function check_risk() {
  const options = buildOptions("", "hr/user/check_risk", "GET");
  return instance(options);
}

export async function risk_list(data: any) {
  const options = buildOptions(data, "hr/user/risk_list");
  return instance(options);
}

export async function invite_sms(data) {
  const options = buildOptions("", "hr/user/invite_sms?id=" + data, "GET");
  return instance(options);
}

export async function risk_check(data) {
  const options = buildOptions("", "hr/detection/risk_check?company_id=" + data, "GET");
  return instance(options);
}

export async function risk_score(data) {
  const options = buildOptions("", "hr/detection/risk_score?company_id=" + data, "GET");
  return instance(options);
}

export async function risk_listapi(data) {
  const options = buildOptions("", "hr/detection/risk_list?company_id=" + data, "GET");
  return instance(options);
}

export async function risk_rescan(data) {
  const options = buildOptions("", "hr/detection/risk_rescan?risk_id=" + data, "GET");
  return instance(options);
}

export async function risk_detail(data) {
  const options = buildOptions(data, "hr/detection/risk_detail");
  return instance(options);
}

//------------------签署中心的

//合同类型
export async function contractType() {
  const options = buildOptions("", "hr/manpower/contractType", "GET");
  return instance(options);
}

export async function manpowerlist(data) {
  const options = buildOptions(data, "hr/manpower/list");
  return instance(options);
}

//员工列表
export async function joinList() {
  const options = buildOptions("", "hr/manpower/joinList", "GET");
  return instance(options);
}
//员工列表
export async function uploadFile(data) {
  const options = buildOptions(data, "hr/manpower/uploadFile");
  return instance(options);
}

//
export async function nextStepApi(data) {
  const options = buildOptions(data, "hr/manpower/nextStep");
  return instance(options);
}
//保存草稿
export async function saveDraftApi(data) {
  const options = buildOptions(data, "hr/manpower/saveDraft");
  return instance(options);
}
//个人三要素发送验证码
export async function authPersonMobile3(data) {
  const options = buildOptions(data, "hr/acsign/authPersonMobile3");
  return instance(options);
}
//个人三要素认证
export async function authCaptchaVerify(data) {
  const options = buildOptions(data, "hr/acsign/authCaptchaVerify");
  return instance(options);
}

//企业三要素发送验证码
export async function authCompanyMobile3(data) {
  const options = buildOptions(data, "hr/acsign/authCompanyMobile3");
  return instance(options);
}

//首页数量
export async function index_count() {
  const options = buildOptions("", "hr/manpower/index_count");
  return instance(options);
}

//拒签
export async function rejectApi(data) {
  const options = buildOptions(data, "hr/manpower/reject");
  return instance(options);
}
//删除
export async function delete_contractApi(id) {
  const options = buildOptions("", "hr/manpower/delete_contract?task_id=" + id, "GET");
  return instance(options);
}

//密码验证
export async function check_passwordApi(data) {
  const options = buildOptions(data, "hr/manpower/check_password");
  return instance(options);
}

//合同详情
export async function getContractDetailApi(id, isDraft) {
  const options = buildOptions("", "hr/manpower/getContractDetail?task_id=" + id + "&isDraft=" + isDraft, "GET");
  return instance(options);
}

//撤销
export async function revokeApi(data) {
  const options = buildOptions(data, "hr/manpower/revoke");
  return instance(options);
}

//合同详情
export async function getTerminationFileApi(id) {
  const options = buildOptions("", "hr/manpower/getTerminationFile?task_id=" + id, "GET");
  return instance(options);
}

//合同详情
export async function getTerminationFileAndUploadApi(id, reason) {
  const options = buildOptions("", "hr/manpower/getTerminationFileAndUpload?task_id=" + id + "&reason=" + reason, "GET");
  return instance(options);
}

//申请区块链存证报告
export async function downloadChainReportApi(id, type) {
  const options = buildOptions("", "hr/manpower/downloadChainReport?id=" + id + "&type=" + type, "GET");
  return instance(options);
}

//规章制度列表
export async function getRegulationListApi(page, limit, rule_status) {
  const options = buildOptions("", "hr/manpower/getRegulationList?page=" + page + "&limit=" + limit + "&rule_status=" + rule_status, "GET");
  return instance(options);
}

export async function contractInvalidApi(task_id, rule_status) {
  const options = buildOptions("", "hr/manpower/contractInvalid?task_id=" + task_id + "&rule_status=" + rule_status, "GET");
  return instance(options);
}

//删除草稿
export async function deleteDraftApi(id) {
  const options = buildOptions("", "hr/manpower/deleteDraft?draft_id=" + id, "GET");
  return instance(options);
}
//manpower/getContractDetail?task_id=25c7219e-f8a1-4132-b753-a6178feced2&isDraft=0
